package com.yuntuzhilian.chapter3;

import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

/**
 * @author MrWang-shuizhishuiheshui
 * @description 字符形式读取
 */
public class TestFileReader {
    public static void main(String[] args) {
        //声明reader对象
        Reader rd=null;

        try {
            //实例化
            rd=new FileReader("test1.txt");
            //创建字符数组
            char[] chars=new char[1024];
            //循环读取
            while((rd.read(chars))!=-1){
                System.out.println(new String(chars));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (rd!=null){
                try {
                    rd.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }


    }
}
